package com.flyxteam.commons.base.util;

import java.nio.charset.Charset;

import org.apache.commons.codec.binary.Base64;

import com.flyxteam.commons.base.consts.GlobalConsts;

/**
 * common
 * <ul>
 * <li>2017-01-01 | ChrisX | + create</li>
 * </ul>
 * @author ChrisX
 */
public class Base64Util {

    private Base64Util() {}
    
    private static final String CHARSET_ENCODING = GlobalConsts.ENCODING;
    
	public static byte[] decode(String text) {
		return Base64.decodeBase64(text.getBytes(Charset.forName(CHARSET_ENCODING)));
	}

	public static String encode(byte[] bytes) {
		return new String(Base64.encodeBase64(bytes), Charset.forName(CHARSET_ENCODING));
	}
}